package com.jy.wms.web;

import com.joyi.gate.comm.SessionInfo;
import com.joyi.gate.safety.vo.UserInfo;
import com.jy.wms.service.SysMenuService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by YUJIE on 2018/9/5
 * 发运订单协助管理.
 */
@Controller
@RequestMapping("/outOrder")
public class WmsOrderAssistance {
    @Autowired
    SysMenuService menuService;

    @RequestMapping(value = "orderAssistance/{menu}")
    public String purchase(@PathVariable("menu") String menu, Model model, HttpSession session) {
        model.addAttribute("functions",menuService.getFunctions(menu));
        UserInfo userinfo = (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        JSONObject userJson = JSONObject.fromObject(userinfo);
        model.addAttribute("UserInfo",userJson.toString());
        return "outOperation/orderAssistance/shipment";
    }

    @RequestMapping(value = "AddShipment")
    public String addshipment() {
        return "outOperation/orderAssistance/addshipment";
    }

    @RequestMapping(value = "EditShipment")
    public String editshipment() {
        return "outOperation/orderAssistance/editshipment";
    }

    // 查看明细
    @RequestMapping(value = "LookDetail")
    public String lookdetail(String id, Model model){
        model.addAttribute("id",id);
        return "outOperation/orderAssistance/lookdetail";
    }

    //修改承运商类别
    @RequestMapping(value = "EditForwardingAgent")
    public String editForwardingAgent(){return "outOperation/orderAssistance/editForwardingaAent";}

    // 查看库存余量
    @RequestMapping(value = "SearchInventory")
    public String searchinventory(){return "outOperation/orderAssistance/searchinventory";}

    // 查看拆单明细
    @RequestMapping(value = "SeparatedDetail")
    public String SeparatedDetail(){return "outOperation/orderAssistance/searchSeparatedDetail";}

    // 查看拆单行
    @RequestMapping(value = "SeparatedRow")
    public String SeparatedRow(String id, Model model){
        model.addAttribute("id",id);
        return "outOperation/orderAssistance/searchSeparatedRow";
    }

    // 查看分配明细
    @RequestMapping(value = "AllocationDetail")
    public String AllocationDetail(){return "outOperation/orderAssistance/searchAllocationDetail";}

    // 查看分配行
    @RequestMapping(value = "AllocationRow")
    public String AllocationRow(String id, Model model){
        model.addAttribute("id",id);
        return "outOperation/orderAssistance/searchAllocationRow";
    }

    // 查看装箱明细
    @RequestMapping(value = "PackingDetail")
    public String PackingDetail(){return "outOperation/orderAssistance/searchPackingDetail";}

    // 查看装箱明细行
    @RequestMapping(value = "PackingDetailRow")
    public String PackingDetailRow(String id,String xbh, Model model){
        model.addAttribute("id",id);
        model.addAttribute("xbh",xbh);
        return "outOperation/orderAssistance/searchPackingRow";
    }

    //查看关联退单
    @RequestMapping(value = "selectTuiDan")
    public String selectTuiDan(){
        return "outOperation/orderAssistance/selectTuiDan";
    }
    //附件管理
    @RequestMapping(value = "/getFuJian")
    public String getFuJian(String id, Model model) {
        model.addAttribute("id",id);
        return "outOperation/orderAssistance/upload";
    }
}
